﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Reflection;
using System.Collections.Specialized;

using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;

using server.Logic;
using WAF.EntityFramework;

namespace server.Remote
{
    /*
    public class GeneralForm
    {
        /// <summary>
        /// 获取要显示的Form的数据
        /// </summary>
        /// <param name="context">请求内容上下文</param>
        /// <returns>Form显示数据</returns>
        public string GetGeneralFormData(HttpContext context)
        {
            Dictionary<string, string> jsonObject = AppEntry.GetPayloadObject(context);

            string entityId = jsonObject["entityId"];
            string entityName = jsonObject["entityName"];

            Type entityType = Common.GetEntityType(entityName);
            System.Collections.ArrayList fields = GetGeneralFormFields(entityName);

            StringWriter sw = new StringWriter();
            JsonTextWriter jsonWriter = new JsonTextWriter(sw);

            //输出开始
            jsonWriter.WriteStartObject();

            //字段信息
            jsonWriter.WritePropertyName("fields");
            jsonWriter.WriteValue(JsonConvert.SerializeObject(fields));

            //字段数据
            if (entityId != null)
            {
                Entity entity = EntityAction.Select(entityType, long.Parse(entityId));

                jsonWriter.WritePropertyName("data");
                jsonWriter.WriteValue(JsonConvert.SerializeObject(entity));
            }

            //输出结束
            jsonWriter.WriteEndObject();
            jsonWriter.Flush();

            return MyHandler.WriteSuccessResult(true, sw.GetStringBuilder().ToString());
        }
    }
     * */
}